package com.lyf.jvm.learn.atsgg.classes.classstructure.sample3;

/**
 * @author LYF
 * @date 2022/7/2
 */

class Father{
    int x=10;
    public Father() {
        this.print();
        x = 30;
    }
    void print(){
        System.out.println("Father x = "+x);
    }
}
class Son extends Father{
    int x = 20;
    public Son() {
        this.print();
        x = 40;
    }
    // 覆盖
    void print(){
        System.out.println("Son x = "+x);
    }
}

public class FatherSonSample {
    public static void main(String[] args) {
        //Father f = new Father();
        Father f = new Son();
        //Son f = new Son();
        System.out.println(f.x);
    }
}
